<!-- eslint-disable vue/multi-word-component-names -->
<template>
  <div class="home-container">
    <h2>首页（已登录）</h2>
    <button @click="logout" class="logout-btn">登出</button>
  </div>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { useUserStore } from '@/stores/useUserStore'

const router = useRouter()
const userStore = useUserStore()

// 登出逻辑
const logout = () => {
  userStore.logout() // 清除 Token，标记为未登录
  router.push('/login') // 跳转到登录页
}
</script>

<style scoped>
.home-container {
  width: 400px;
  margin: 100px auto;
  padding: 20px;
  border: 1px solid #eee;
  border-radius: 8px;
}
.logout-btn {
  padding: 8px 16px;
  background-color: #f56c6c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}
.logout-btn:hover {
  background-color: #f78989;
}
</style>
